using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Pokemon
{
    public class Item : DrawableGameComponent
    {
        #region Attribute

        protected enum ItemState
        {
            Stand,
            Move,
            Attack,
            Hit,
            Destroy,
        }

        protected ItemState _state = ItemState.Stand;

        protected List<Sprite> _textures = new List<Sprite>();        

        protected Vector2 _size;

        protected Vector2 _position;                

        protected Color _color;        

        protected Blank _owner;       

        protected TimeSpan _LifeTime;

        protected string _path;

        protected TimeSpan _delayTime;

        #endregion

        #region Method
        /// <summary>
        /// constructor 
        /// </summary>
        /// <param name="game"></param>
        /// <param name="owner">indicate what blank contains the item</param>
        /// <param name="position">position of the item on game play screen</param>
        /// <param name="spriteBatch">object we use to draw a picture on screen</param>
        protected Item(Game game, string path, Blank owner, Vector2 position)
            : base(game)
        {
            _owner = owner;

            _path = path;

            _position = position;                            
        }

        /// <summary>
        /// Initalize all information before the game play
        /// </summary>
        public override void Initialize()
        {            
            _color = Color.White;
            base.Initialize();
        }

        public override void Update(GameTime gameTime)
        {            
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {            
            SpriteBatch _SpriteBatch = (SpriteBatch)Game.Services.GetService(typeof (SpriteBatch));
            _textures[0].Draw(_SpriteBatch, _position, _color);
            //_SpriteBatch.Draw(_textures[0], _position, rect, _color);
            base.Draw(gameTime);
        }        

        /// <summary>
        /// return Center Point of the item        
        /// </summary>
        /// <returns></returns>
        public virtual Point GetCenterPoint(int index)
        {
            return new Point((int)_position.X + (int)_textures[index].CenterPoint.X, (int)_position.Y + (int)_textures[index].CenterPoint.Y);
        }

        /// <summary>
        /// dispose the item
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            if (_owner != null)
                _owner.Remove(this);
            //UnloadContent();                  
            base.Dispose(disposing);
        }
        #endregion

    }
}
